'''
    该案例演示while循序
    第1周有2只兔子，
    此后每周兔子的数量都增加上周数量的2倍，
    且期间没有兔子死亡，求第10周共有多少只兔子：
'''
import time

week = 1
rabbit =2
while week < 10:
    rabbit = rabbit + rabbit *2
    week += 1
print(rabbit)


# ------------再来一个案例---------------------
#打印进度条
# num =1
# while num <= 20:
#     print("\r"+"="*num,end=" ")
#     num += 1
#     time.sleep(0.5)
# print("完毕")

# -----------while  else----------------------
# week = 1
# rabbit =2
# while week < 10:
#     rabbit = rabbit + rabbit *2
#     week += 1
#     if week == 5:   # break 终止 到第五周就停止 不会执行else语句
#         break
#     print(f"第{week}周有{rabbit}只兔子")
# else:
#     print(f"第{week}周有{rabbit}只兔子")
